package com.block.api.controller.sys;

import cn.hutool.core.util.RandomUtil;
import com.alibaba.fastjson.JSONObject;
import com.block.common.bean.SessionBean;
import com.block.common.constant.AppRspCodeConstant;
import com.block.common.exception.ApiException;
import com.block.common.security.util.ApiUtil;
import com.block.common.vo.ResponseVo;
import com.block.db.entity.AppEncrypt;
import com.block.db.entity.ApplicationInfo;
import com.block.db.entity.ChannelBaseInfo;
import com.block.sms.service.ISmsRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

@RestController
@RequestMapping("api/home")
@Validated
public class HomeController {

    @Autowired
    ISmsRecordService smsRecordService;

    /**
     * 主页信息
     *
     */
    @RequestMapping(value = "/mainInfo", method = {RequestMethod.POST, RequestMethod.GET})
    public String mainInfo(@RequestAttribute(value = "tranData") JSONObject tranData,
                              @RequestAttribute(value = "appEncrypt") AppEncrypt appEncrypt,
                                @RequestAttribute(value = "channelBaseInfo") ChannelBaseInfo channelBaseInfo,
                                @RequestAttribute(value = "applicationInfo") ApplicationInfo applicationInfo,
                                @RequestAttribute(value = "uri") String uri,
                                @RequestAttribute(value = "startDate") Date startdate,
                                @RequestAttribute(value = "ip") String ip) throws ApiException {

        JSONObject jsonObject = new JSONObject();
        jsonObject.put("toLoan", "0");//0 敬请期待 1 跳产品
        jsonObject.put("randomUuid", RandomUtil.randomString(32));//

        ResponseVo responseVo = new ResponseVo(AppRspCodeConstant.SUCCESS, jsonObject);
        return ApiUtil.dealReturnJson(responseVo, appEncrypt, startdate, uri);
    }

}
